//! \file backtracer_linux_elf.h

#include <link.h>

#include "map_utils.h"
#include "defs.h"

//-----------------------------------------------------------------------------

#ifndef _BACKTRACER_LINUX_ELF_H_
#define _BACKTRACER_LINUX_ELF_H_

//-----------------------------------------------------------------------------

#define SYMBOLS_COUNT_START 100

#define ARM_REG_FP 11
#define ARM_REG_PC 15

//-----------------------------------------------------------------------------

typedef struct {
    unsigned long symtab; 
    unsigned long strtab; 
    unsigned long gnutab; 
    int nchains;
} elf_session;

//-----------------------------------------------------------------------------

TBGError ElfGetDynamicFuncMap(func_map *pmap); 

TBGError ElfResolveTables(struct link_map *pl_map, elf_session *pelf); 

int ElfGetMaxOldSymbolsCount(elf_session *pelf); 

TBGError ElfGetAllSymbolsOld(elf_session *pelf, func_map_info *map_arr_out,
                             name_t *names, size_t max_count, int *pgot_count);

TBGError ElfGetAllSymbolsGNU(elf_session *pelf, func_map_info *map_arr_out, 
                             name_t *names, size_t max_count, int *pgot_count);

//static uint_fast32_t dl_new_hash (const char *s); 

//-----------------------------------------------------------------------------

#endif //_BACKTRACER_LINUX_ELF_H_

